#ifndef WebSocketCaster_H
#define WebSocketCaster_H

#include "HttpServer.h"
#include <vector>
#include <memory>

class WebSocketCaster : public HttpHandler
{
public:
	WebSocketCaster();
	~WebSocketCaster();

	bool start(int port);
	
	void stop();
	
	bool isStarted();

	void sendBinary(void* data, size_t size);
	
	void sendText(const std::string& text);

protected:
	virtual int handleJsonApi(HttpRequest& request, std::string& json);

	virtual void handleUpload(const char* name, const std::string& filepath);

	virtual int handleFileApi(HttpRequest& request, std::string& resp, std::string& mime);

	virtual void handleWebSocketFrame(unsigned char *data, size_t size, unsigned char flags);

protected:
	std::shared_ptr< HttpServer >	m_server;

};

#endif // WebSocketCaster_H